<?php
/**
 * @author qingyu8@staff.weibo.com
 * @date 2018/02/28
 */
namespace common\logic;

use common\models\Product;
use yii;
use common\models\TripProductRel as TripProductRelModel;

class TripProductRel {

    public static function getRental($tripId) {
        $res = TripProductRelModel::getDb()->createCommand("SELECT a.product_id,a.price,b.name_cn FROM `trip_product_rel` AS a JOIN `product` AS b ON a.product_id=b.id WHERE a.trip_id=$tripId AND b.type=" . Product::TYPE_RENTAL)->queryAll();
        return $res;
    }
    public static function getCourse($tripId) {
        $res = TripProductRelModel::getDb()->createCommand("SELECT a.product_id,a.price,b.name_cn FROM `trip_product_rel` AS a JOIN `product` AS b ON a.product_id=b.id WHERE a.trip_id=$tripId AND b.type=" . Product::TYPE_COURSE)->queryAll();
        return $res;
    }


}
